home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / ins_msc / imc9104 / blank.c next >
Text File  |  1991-03-05  |  1KB  |  35 lines

  1. /*******************************************************************
  2. * BLANK.C - Call new command processor with a nearly blank         *
  3. *           environment.                                           *
  4. *                                                                  *
  5. * To compile: cl BLANK.C                                           *
  6. *******************************************************************/
  7.  
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <process.h>
  11.  
  12. void main(void)
  13.     {
  14.    int i,j;
  15.     char *path, *tmp;
  16.  
  17.     /* Save the current path into variable "path"   */
  18.     path = strdup(getenv("PATH")-strlen("PATH="));
  19.  
  20.     /* Delete all environment variables             */
  21.     while (environ[0])
  22.         {
  23.         tmp = strdup(environ[0]);
  24.         tmp[strchr(tmp,'=') - tmp + 1] = 0;
  25.         putenv(tmp);
  26.         free(tmp);
  27.         }
  28.  
  29.     /* Set new PATH and PROMPT environment vars     */
  30.     /* and run a new copy of the command processor  */
  31.     putenv(path);
  32.     putenv("PROMPT=Type EXIT to return > ");
  33.     execlp("command", NULL);
  34.     }
  35.